package javaCode.chapter07.object_;

public class EqualsExercise02 {
    public static void main(String[] args) {

        Person_ p1 = new Person_("xzc");
        Person_ p2 = new Person_("xzc");
        System.out.println(p1 == p2); //f 判断的是对象
        System.out.println(p1.name.equals(p2.name)); //t p1.name是字符串 字符串重写了equals 所以判断的是值
        System.out.println(p1.equals(p2)); //f


        String s1 = new String("nick");
        String s2 = new String("nick");
        System.out.println(s1.equals(s2)); //t
        System.out.println(s1 == s2); //f
    }
}

class Person_{
    public String name;

    public Person_(String name) {
        this.name = name;
    }
}